package com.xscr.api.utils;


public class CodeUtil {
	
	/**
	 * 获取订单编号
	 */
	public static String getXSCROrderCode() {
		/*if (mfOrderCounter.get() > 999999) {
			mfOrderCounter.set(1);
		}*/
		RandomGUID myGUID = new RandomGUID();
		StringBuffer buffer  = new StringBuffer();
		buffer.append("XSCR");
		buffer.append(DateUtil.getCurDateStr("yyyyMMdd"));
		/*buffer.append(String.format("%06d", mfOrderCounter.getAndIncrement()));*/
		buffer.append(myGUID.toString().substring(0,6));
		return buffer.toString();
	}
	
	/**
	 * 将订单转成32位
	 * @param orderId
	 * @return
	 */
	public static String getpayOrderId(Integer orderId){
		String str = String.valueOf(orderId);
		int strLen = str.length();
	     StringBuffer sb = null;
	     while (strLen < 32) {
	           sb = new StringBuffer();
	           sb.append("0").append(str);// 左(前)补0
	        // sb.append(str).append("0");//右(后)补0
	           str = sb.toString();
	           strLen = str.length();
	     }
	     return str;
	}
	
	/**
	 * @Description:获取32位字符串
	 * @param ordercode
	 * @return
	 * @throws
	 */
	public static String getpayOrderCode(String ordercode){
		RandomGUID myGUID = new RandomGUID();
		StringBuffer buffer  = new StringBuffer();
		buffer.append(ordercode);
		buffer.append(DateUtil.getCurDateStr("yyyyMMddHHmm"));
		buffer.append(myGUID.toString().substring(0,4));
		return buffer.toString();
	}
	
	
}
